/**
* 财务管理路由
**/
'use strict';
import reviewCtl from './review'

import gatheringCtl from './gathering'//收款明细
import paymentCtl from './payment'//付款明细
import detailCtl from './detail'//查看订单

module.exports = angular.module('app.finance', []).config(function($stateProvider) {
    $stateProvider.state('finance', {
        url: '/finance',
        templateProvider: function($q) {
            var deferred = $q.defer();
            require.ensure(['../layout.html'], function(require) {
                var template = require('../layout.html');
                deferred.resolve(template);
            }, 'finance-tpl');
            return deferred.promise;
        },
        controller: 'financeCtrl',
        controllerAs: 'vm',
        resolve: {
            'app.finance': function($q, $ocLazyLoad) {
                var deferred = $q.defer();
                require.ensure(['./index.js'], function() {
                    var mod = require('./index.js');
                    $ocLazyLoad.load({
                        name: 'app.finance'
                    });
                    deferred.resolve(mod.controller);
                }, 'finance-ctl');
                return deferred.promise;
            }
        }
    })
     .state('finance.detail', {
        url: '/detail?oid?pid?s_id',//查看订单
        views: {
            'content': {
                templateProvider: function($q) {
                    var deferred = $q.defer();
                    require.ensure(['./detail/index.html'], function(require) {
                        var template = require('./detail/index.html');
                        deferred.resolve(template);
                    }, 'finance.detail-tpl');
                    return deferred.promise;
                },
                controller:detailCtl
            }
        }
    })
    .state('finance.review', {
        url: '/review',
        views: {
            'content': {
                templateProvider: function($q) {
                    var deferred = $q.defer();
                    require.ensure(['./review/index.html'], function(require) {
                        var template = require('./review/index.html');
                        deferred.resolve(template);
                    }, 'finance.review-tpl');
                    return deferred.promise;
                },
                controller:reviewCtl
            }
        }
    })
    .state('finance.gathering', {
        url: '/gathering',
        views: {
            'content': {
                templateProvider: function($q) {
                    var deferred = $q.defer();
                    require.ensure(['./gathering/index.html'], function(require) {
                        var template = require('./gathering/index.html');
                        deferred.resolve(template);
                    }, 'finance.gathering-tpl');
                    return deferred.promise;
                },
                controller:gatheringCtl
            }
        }
    })
    .state('finance.payment', {
        url: '/gathering/payment',
        views: {
            'content': {
                templateProvider: function($q) {
                    var deferred = $q.defer();
                    require.ensure(['./payment/index.html'], function(require) {
                        var template = require('./payment/index.html');
                        deferred.resolve(template);
                    }, 'finance.payment-tpl');
                    return deferred.promise;
                },
                controller:paymentCtl
            }
        }
    })
}).name;
